home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #4 / Amiga Plus CD - 2000 - No. 4.iso / Tools / Grafik / Misc / ImageEnginer / ARexx / Batch / Max_Med_Min_Local.ieb < prev    next >
Encoding:
Text File  |  1997-02-02  |  3.5 KB  |  141 lines

  1. /*
  2. ** $VER: Max_Med_Min_Local.ieb 1.1, IE Arexx script
  3. ** Image Engineer Batch Processing script
  4. ** Copyright © by Patrik M Nydensten
  5. ** 25/1 1997 Stockholm/Sweden
  6. **
  7. ** Apply Maximum, Median, Minimum or Local_contrast_stretch
  8. ** filter to image.
  9. */
  10.  
  11. options results
  12. signal on error
  13.  
  14. parse arg input command
  15. input = upper(strip(input))
  16. address 'IMAGEENGINEER'
  17.  
  18. select  /* Required batch script commands */
  19.   when input = 'INFO' then    return get_info()
  20.   when input = 'CONFIG' then  return get_config(command)
  21.   when input = 'PROCESS' then return process_image(command)
  22.   otherwise do
  23.     'REQUEST' '"Failure in call to batch script!"' '" Quit "'
  24.     return '<ERROR>'
  25.   end
  26. end
  27.  
  28. exit 0
  29.  
  30. /* Required "Get_info" procedure  ------------------------------------ */
  31. /* S = SECONDARY, A = ALPHA, 1 = Single file, 2 = Multiple files       */
  32.  
  33. get_info:
  34.   back = 'OK'
  35. return back
  36.  
  37. /* Required "Get_config" procedure  ---------------------------------- */
  38.  
  39. get_config:
  40.   parse arg '"'command'"'
  41.  
  42.   Width=5 ; Height=5
  43.  
  44.   if command ~= '' then parse var command Width Height '#'CalcType
  45.  
  46.   'IE_TO_FRONT'
  47.  
  48.   form = 'FORM "Highpass" " OK | Cancel "',
  49.   ' INTEGER,"Mask width",1,25,'Width',SLIDER',
  50.   ' INTEGER,"Mask width",1,25,'Height',SLIDER'
  51.  
  52.   if command = '' then do
  53.     form = form||' CYCLE,"Filter type:","Maximum|Median|Minimum|Local contrast stretch",0'
  54.  
  55.     form
  56.     parse var result ok Width Height CalcType
  57.     if ok = 0 then return '<ERROR>'
  58.  
  59.     select
  60.       when CalcType = 0 then CalcType = 'MAX'
  61.       when CalcType = 1 then CalcType = 'MED'
  62.       when CalcType = 2 then CalcType = 'MIN'
  63.       when CalcType = 3 then CalcType = 'LOCAL'
  64.     end
  65.   end
  66.   else do
  67.     form
  68.     parse var result ok Width Height
  69.  
  70.     CalcType = 'none'
  71.   end
  72.  
  73.   back = Width Height '#'CalcType
  74. return back
  75.  
  76. /* Required "Process_image" procedure  ------------------------------- */
  77.  
  78. process_image:
  79.   parse arg '"'src_image'"' '"'dst_image'"' '"'options'"'
  80.   parse var options Width Height '#'CalcType
  81.  
  82.   'OPEN' '"'src_image'"' '24'
  83.   if (RC ~= 0) then do
  84.     'IE_TO_FRONT'
  85.     'REQUEST' '"Failed to load image:' d2c(10)||src_image'"' '" OK "'
  86.     return '<ERROR>'
  87.   end
  88.   else LoadImage = result
  89.  
  90.   if CalcType = 'MAX' then do
  91.     'MAXIMUM' LoadImage Width Height
  92.     OutputImage = result
  93.   end
  94.   if CalcType = 'MED' then do
  95.     'MEDIAN' LoadImage Width Height
  96.     OutputImage = result
  97.   end
  98.   if CalcType = 'MIN' then do
  99.     'MINIMUM' LoadImage Width Height
  100.     OutputImage = result
  101.   end
  102.   if CalcType = 'LOCAL' then do
  103.     'LOCAL_CONTRAST_STRETCH' LoadImage Width Height
  104.     OutputImage = result
  105.   end
  106.  
  107.   'CLOSE' LoadImage
  108.  
  109.   if getclip('cfg_save_frmt')='' then setclip('cfg_save_frmt','ILBM CmpByteRun1')
  110.   'SAVE_DATA' OutputImage '"'dst_image'"' '"'getclip('cfg_save_frmt')'"'
  111.   if (RC ~= 0) then do
  112.     'IE_TO_FRONT'
  113.     'REQUEST' '"Failed to save image:' d2c(10)||dst_image'"' '" OK "'
  114.     return '<ERROR>'
  115.   end
  116.   'CLOSE' OutputImage
  117.  
  118.   back = 'OK'
  119. return back
  120.  
  121. /* Internal procedures  ---------------------------------------------- */
  122.  
  123. /*******************************************************************/
  124. /* This is where control goes when an error code is returned by IE */
  125. /* It puts up a message saying what happened and on which line     */
  126. /*******************************************************************/
  127.  
  128. error:
  129. if RC=5 then do
  130.     IE_TO_FRONT
  131.     LAST_ERROR
  132.     'REQUEST "'||RESULT||'"'
  133. end
  134. else do
  135.     IE_TO_FRONT
  136.     LAST_ERROR
  137.     'REQUEST "Error detected!!!'||D2C(10)||'Image Engineer error message is as follows'||D2C(10)||result||D2C(10)||'Script failed on line '||SIGL||'"' 'Doh!'
  138. end
  139.  
  140. return '<ERROR>'
  141.